﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="Caifu.WebSite.Register" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>用户中心 - 财富520</title>
    <link href="Style/Default.css" rel="stylesheet" type="text/css" />
    <script src="Scripts/Page.js" type="text/javascript"></script>
    <script src="Scripts/Verification.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">

        //引入选择器
        var Dom = Page.tool.Dom;

        //更换验证码图片
        function ChangeImg(img, key, url) {
            url = url || "../PassCode.ashx";
            url += "?k=" + key + "&r=" + Math.random();
            img.src = url;
        }

        //开启注册验证码
        function StartVerifyCode(panel, img, key, url) {
            panel.show();
            ChangeImg(img, key, url);
        }

        //注册表单验证对象
        var register = new form(['mail', function () { VerifyMail(); } ],
         ["pwd", function () { VerifyPwd(); } ], ["repwd", function () { VerifyRePwd(); } ]);

        //初始化邮箱验证对象
        function VerifyMail() {
            if (!register.controls.mail) {
                if (register.controls.mail = Verification.Create(Dom.$("txtruername"),
                 new Monitor(Dom.$('rmailtip'), "", "error-tip"), /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/)) {
                    register.controls.mail.testEmpty.preventMessage = '请输入邮箱地址';
                    register.controls.mail.testRegular.preventMessage = '邮箱地址格式错误';
                }
                else {
                    register.error.count++;
                    register.error.mail = "error";
                }
            }
        }

        //验证密码
        function VerifyPwd() {
            if (!register.controls.pwd) {
                if (register.controls.pwd = Verification.Create(Dom.$('txtrpwd'),
                 new Monitor(Dom.$('rpwdtip'), '', "error-tip"), /^[0-9a-zA-Z][0-9a-zA-Z]*?$/)) {
                    register.controls.pwd.testEmpty.preventMessage = '请输入密码';
                    register.controls.pwd.testRegular.preventMessage = '6-16位字母或数字';
                }
                else {
                    register.error.count++;
                    register.error.pwd = "error";
                }
            }
        }

        //验证重复密码
        function VerifyRePwd() {
            if (!register.controls.repwd) {
                if (register.controls.repwd = Verification.Create(Dom.$('txtrerpwd'),
                new Monitor(Dom.$('rerpwdtip'), '', "error-tip"), /^[0-9a-zA-Z][0-9a-zA-Z]*?$/)) {
                    register.controls.repwd.expand(
                        { key: "testSame", core: new Component("两次密码输入不一致", function () {
                            if (this.value() != register.controls.pwd.value()) {
                                this.valid = false;
                                this.monitor.InvalidShow(this.testSame.preventMessage);
                            }
                        })
                        });
                    register.controls.repwd.testEmpty.preventMessage = '请输入确认密码';
                    register.controls.repwd.testRegular.preventMessage = '6-16位字母或数字';
                }
                else {
                    register.error.count++;
                    register.error.repwd = "error";
                }
            }
        }

        /**
        *以下代码为登录
        **/

        //登录验证
        var LoginForm = new form(["email", function () {
            if (LoginForm.controls.email = Verification.Create(Dom.$('txtmail'),
                new Monitor(Dom.$('loginTip'), '', "login-error-tip"))) {
                LoginForm.controls.email.testEmpty.preventMessage = '请输入账号！';
            }
            else {
                LoginForm.error.count++;
                LoginForm.error.account = "error";
            }
        } ], ["password", function () {
            if (LoginForm.controls.password = Verification.Create(Dom.$("txtpwd"),
                 new Monitor(Dom.$('loginTip'), '', "login-error-tip"))) {
                LoginForm.controls.password.testEmpty.preventMessage = '请输入密码！';
            }
            else {
                LoginForm.error.count++;
                LoginForm.error.pwd = "error";
            }
        } ]);

        //验证账号信息
        function VerifyAccount() {
            if (LoginForm.check()) {
                var ajax = new Page.Ajax();
                ajax.postDataReturnText("Login.ashx?r=" + Math.random(), "name=" + LoginForm.controls.email.value() +
                "&pwd=" + LoginForm.controls.password.value() + "&verifyCode=" + Dom.$("txtLogVCode").value, Handle);
            }
        }

        //登录回调
        function Handle(result) {
            eval(result);
            if (loginResult) {
                if (loginResult.s == 20000) {
                    var cookie = new Page.Cookie("u", loginResult.t);
                    cookie.path = "/";
                    if (Dom.$("autoLogin").checked) {
                        var timer = new Date();
                        timer.setTime(timer.getTime() + 30 * 24 * 3600 * 1000);
                        cookie.expires = timer.toUTCString();
                    }
                    cookie.store();
                    window.location.href = "PrintCookie.aspx";
                }
                else if (loginResult.s == 40003) {
                    alert("验证码错误或者过期");
                }
                else {
                    alert("用户名或者密码错误");
                }
                if (loginResult.Captcha) {
                    StartVerifyCode(Dom.$("LogPanel"), Dom.$("LogVCodeImg"), 'log');
                }
            }
            else {
                alert("未知错误，登录失败");
            }
        }    
    </script>
</head>
<body>
    <div class="head">
        <div class="logo">
            <img src="images/logo.gif" alt="财富520" width="170" height="40" />
        </div>
        <div class="search">
            <input type="text" class="chaxun_input" id="sKeyWord" style="padding: 0px 0px 0px 10px;
                margin: 10px 0px 0px 0px" value="基金名称/代码/简拼 " />
            <div class="btn" onclick="alert('功能开发中……');">
                查询</div>
        </div>
        <div class="channel">
            <a class="denglu" href="#" target="_blank">登录</a> <a href="#" target="_blank">注册</a>
        </div>
    </div>
    <div class="quotation01">
        <div class="quo02">
            <b>上证指数：</b> <span class="sp3">3005.49</span> <span class="sp2">4.13 (0.14%)</span>
        </div>
        <div class="quo02 quo02">
            <b>深证指数：</b> <span class="sp3">12848.02</span> <span class="sp1">-156.84 (-1.21%)</span>
        </div>
        <div class="quo02 quo03">
            <b>沪深300：</b> <span class="sp3">3247.87</span> <span class="sp1">-32.39 (-0.99%)</span>
        </div>
    </div>
    <form id="Register" runat="server">
    <div class="content">
        <div class="login">
            <label for="txtmail">
                账&nbsp;号：<input type="text" title="注册的邮箱" id="txtmail" name="mail" class="input-text"
                    maxlength="50" />
            </label>
            <br />
            <br />
            <label for="txtpwd">
                密&nbsp;码：<input type="password" title="注册时填写的密码" id="txtpwd" name="pwd" class="input-text"
                    maxlength="16" />
            </label>
            <br />
            <br />
            <div id="LogPanel" style="display: none;">
                <label for="txtLogVCode">
                    验证码
                </label>
                <input type="text" id="txtLogVCode" class="inputtext" style="width: 70px;" name="LogVCode" />
                <img id="LogVCodeImg" width="80px" alt="登录验证码" onclick="ChangeImg(this, 'log');"
                    title="单击换一张" src="#" />
            </div>
            <br />
            <br />
            <label title="为了确保您的信息安全，请不要在网吧或者公共机房勾选此项！" for="autoLogin" class="labelCheckbox">
                <input type="checkbox" name="autoLogin" id="autoLogin" value="true" tabindex="3" />下次自动登录
            </label>
            <br />
            <br />
            <div style="width: 100%; text-align: center;">
                <input type="button" onclick="VerifyAccount();" class="input-submit" value="登录" />
            </div>
            <br />
            <br />
            <div id="loginTip">
            </div>
        </div>
        <div class="register">
            <h3 style="color: rgb(0, 94, 172);">
                快速注册财富号》
            </h3>
            <br />
            <br />
            <label for="txtruername">
                电子邮箱：</label>
            <input type="text" id="txtruername" onfocus="this.value='';" name="rusername" title="输入您常用的邮箱地址" class="inputtext"
                maxlength="50" /><small id="rmailtip"></small>
            <br />
            <br />
            <label for="txtrpwd">
                设置密码：</label>
            <input type="password"  onfocus="this.value='';"  id="txtrpwd" name="rpwd" title="尽量使用字母和数字的结合" class="inputtext"
                maxlength="16" /><small id="rpwdtip"></small>
            <br />
            <br />
            <label for="txtrerpwd">
                重复密码：</label>
            <input type="password" id="txtrerpwd"  onfocus="this.value='';"  name="rerpwd" title="请再次输入您的密码" class="inputtext"
                maxlength="16" /><small id="rerpwdtip"></small>
            <br />
            <br />
            <div id="RegVPanel" style="display: none;">
                <label for="txtRegVCode">
                    &nbsp; 验证码：
                </label>
                <input type="text"  onfocus="this.value='';"  id="txtRegVCode" maxlength="4" class="inputtext" style="width: 70px;"
                    name="RegVCode" />
                <img id="RegVCodeImg" width="80px" onclick="ChangeImg(this, 'reg');" title="单击换一张"
                    alt="注册验证码" src="#" />
            </div>
            <br />
            <br />
            <div style="width: 100%; text-align: center;">
                <input type="submit" onclick="return register.check();" class="input-submit" value="注册" />
            </div>
        </div>
    </div>
    <div class="feedback" style="clear: both;">
        关于caifu520 问题反馈
    </div>
    </form>
</body>
</html>
